<!DOCTYPE hrml>

<html>

<head>

    <title>店铺审核</title>

    <include file='public/head'>

    <style>

        .layui-legend-size{font-size:14px !important;}

        .layui-nopadding{padding:0 !important;}

        .layui-overflow{overflow:auto;}

        .layui-nomargin{margin: 0 !important;}

        .layui-bottom{border-bottom:1px solid rgb(226, 226, 226);}

        .layui-input{height:30px !important; }

        .layui-form-search-item .layui-inline{margin-bottom: 5px;} 

        .layui-form-search-item label{margin-left: 15px;}

        .layui-table-page {padding: 7px 0px 0px;}

        .layui-field-padding{border-width: 1px;padding:0 0 5px 10px;}

    </style>

</head>

<body>

    <!-- layui-tab开始 -->

    <div class="layui-tab" lay-fliter="demo-tab">

        <!-- 顶部导航菜单开始 -->

        <div class="layui-tab-nav">

            <ul class="layui-tab-title">

                {:getNav('store','audit_store/index')};

            </ul>

        </div>

        <!-- 顶部导航菜单结束 -->

        <br>

        <!-- 内容开始 -->

        <div class="layui-card">

            <!-- 搜索栏开始 -->

            <fieldset class="layui-elem-field layui-field-title layui-field-padding">

                <legend class="layui-legend-size">搜索</legend>

                <form class="layui-form table-bar" action="{:cmf_plugin_url('Store://audit_store/index')}" lay-filter="form-bar" method="post">

                    <div class="layui-form-search-item">

                        

                        <div class="layui-inline" >

                            <div class="layui-input-inline" style="width: 100px;">

                                <select name="search[type]" lay-verify="" class="layui-input">

                                    <option value="1" <eq name="search.type" value="1">selected</eq> >店铺名称</option>

                                    <option value="2" <eq name="search.type" value="2">selected</eq> >店铺ID</option>

                                </select>

                            </div>

                            <div class="layui-input-inline" style="width: 100px;">

                                <input type="text" name="search[title]" autocomplete="off" placeholder="请输入内容" class="layui-input" value="{$search.title}" style="width: 100px;">

                            </div>

                        </div>



                        <label>审核状态</label>

                        <div class="layui-inline" >

                            <div class="layui-input-inline" style="width: 100px;">

                                <select name="search[status]" lay-verify="" class="layui-input">

                                    <option value="" <eq name="search.status" value="">selected</eq> >全部</option>

                                    <option value="1" <eq name="search.status" value="1">selected</eq> >审核中</option>

                                    <option value="2" <eq name="search.status" value="2">selected</eq> >审核通过</option>

                                    <option value="3" <eq name="search.status" value="3">selected</eq> >审核驳回</option>

                                </select>

                            </div>

                        </div>



                        <div class="layui-inline">

                        <button type="submit" class="layui-btn layui-btn-sm layui-btn-primary " style="font-weight:800;" lay-submit="" lay-filter="demo2"><i class="layui-icon ">&#xe615;</i>搜索</button>

                        </div>

                        

                    </div>

                </form>

            </fieldset>

            <!-- 搜索栏结束 -->



			<!-- 表头按钮开始 -->

			<div class="layui-card-header layui-bg-gray layui-bottom">

                <a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-danger batchReject-btn" >批量驳回<i class="layui-icon">&#x1006;</i></a>
                <a href="javascript:;" class="layui-btn layui-btn-xs batchAudit-btn" >批量通过<i class="layui-icon">&#xe605;</i></a>


            

			</div>

            <!-- 表头按钮结束 -->

            

            <!-- 数据表格开始 -->

            <form method="post"  id="f">

            <table class="layui-table layui-nomargin">

                <thead>

                    <tr>

                        <th rowspan="2" style="text-align:center;">

                            <input type="checkbox"  id="check-box-all" >

                        </th>

                        <th>店铺ID</th>

                        <th>店铺名称</th>

                        <th>审核状态</th>

                        <th>操作时间</th>

                        <th>操作</th>

                    </tr>

                    

                </thead>

                <tbody>

                    <volist  name="data" id="vo">

                        <tr lay-fliter="test3">

                            <th style="text-align:center;">

                                <input type="checkbox" class="check-box " name="id[]" value="{$vo['store_id']}">

                             </th>

                            <td>{$vo.store_id}</td>

                            <td>{$vo.store_name}</td>

                            <td><switch name="vo.store_status">

                                <case value="1">审核中</case>

                                <case value="2">审核通过</case>

                                <case value="3">驳回</case>

                                <default/>???

                                </switch>

                            </td>

                            <td>{:date('Y-m-d H:i:s',$vo.time)}</td>

                            <td>
                                <eq name="vo.store_status" value="1">

                                <button type="button" data-id="{$vo.store_id}" class="layui-btn layui-btn-primary layui-btn-xs adopt-btn" title="通过"><i class="layui-icon">&#xe605;</i></button>

                                <button type="button" data-id="{$vo.store_id}" class="layui-btn layui-btn-primary layui-btn-xs reject-btn" title="驳回"><i class="layui-icon">&#x1006;</i></button>

                                </eq>
                                <button type="button" data-id="{$vo.store_id}" class="layui-btn layui-btn-primary layui-btn-xs log-btn" title="日志"><i class="layui-icon">&#xe60a;</i></button>

                                <button type="button" data-id="{$vo.store_id}" class="layui-btn layui-btn-primary layui-btn-xs details-btn" title="查看详情"><i class="layui-icon">&#xe602;</i></button>
                            </td>

                        </tr>

                    </volist>

                </tbody>

            </table>



            <!--分页-->

            <div class="layui-table-page">

                <div id="layui-table-page1">

                    <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">

                        {$page|default=''}

                    </div>

                </div>

            </div>



            </form>

            <!-- 数据表格结束 -->

        </div>

        <!-- 内容结束 -->



    </div>

    <!-- layui-tab结束 -->

    <include file='public/scripts'>



    <script>

    //全选/取消
    $('#check-box-all').on('click',function(){	
        $('.check-box').prop('checked',$('#check-box-all').prop('checked'));
    }); 









    //审核通过

	$('.adopt-btn').on('click',function(){
        let id = $(this).data('id');
        //询问
        layer.confirm('确定审核通过吗？',{icon:3,title:'提示',btn:['通过','取消']}
        ,function(index,layero){
            console.log(111);
            $.ajax({
                url:"{:cmf_plugin_url('Store://audit_store/audit')}",
                type:'post',
                data:{id:id},
                success:function(data){
                    let icon = ( data.status == 'success' ) ? 1 : 5 ;
                    layer.msg( data.message , { time:1200 , icon:icon },function(){
                        window.location.reload();
                    });
                },
                error:function(data){
                    console.log(data);
                    layer.msg('系统错误',{time:1200,icon:5});
                }
            })   
        },function(index){});

    })



    //批量通过

	$('.batchAudit-btn').on('click',function(){

        var id = $('#f').serialize();

        //询问

        layer.confirm('确定审核通过吗？',{icon:3,title:'提示',btn:['通过','取消']}

        ,function(index,layero){

            console.log(111);

            $.ajax({

                url:"{:cmf_plugin_url('Store://audit_store/batchAudit')}",

                type:'post',

                data:id,

                success:function(data){

                    let icon = ( data.status == 'success' ) ? 1 : 5 ;

                    layer.msg( data.message , { time:1200 , icon:icon },function(){

                        window.location.reload();

                    });

                },

                error:function(data){

                    console.log(data);

                    layer.msg('系统错误',{time:1200,icon:5});

                }

            })   

        },function(index){});

       

    })

        

	//审核驳回

	$('.reject-btn').on('click',function(){

		let id = $(this).data('id');

        layer.prompt({

            formType: 2,

            value: '',

            title: '驳回原因',

            area: ['500px', '400px'] //自定义文本域宽高

            }, function(value, index, elem){

                $.ajax({

                    url:"{:cmf_plugin_url('Store://audit_store/reject')}",

                    type:'post',

                    data:{id:id,reason:value},

                    success:function(data){

                        let icon = ( data.status == 'success' ) ? 1 : 5 ;

                        layer.msg( data.message , { time:1200 , icon:icon },function(){

                            window.location.reload();

                        });

                    },

                    error:function(data){

                        console.log(data);

                        layer.msg('系统错误',{time:1200,icon:5});

                    }

                }) 

            layer.close(index);

            });

	});



	//批量驳回

	$('.batchReject-btn').on('click',function(){

        var id = $('#f').serialize();

        layer.prompt({

            formType: 2,

            value: '',

            title: '驳回原因',

            area: ['500px', '400px'] //自定义文本域宽高

            }, function(value, index, elem){

                $.ajax({

                    url:"{:cmf_plugin_url('Store://audit_store/batchReject')}?reason="+value,

                    type:'post',

                    data:id,

                    success:function(data){

                        let icon = ( data.status == 'success' ) ? 1 : 5 ;

                        layer.msg( data.message , { time:1200 , icon:icon },function(){

                            window.location.reload();

                        });

                    },

                    error:function(data){

                        console.log(data);

                        layer.msg('系统错误',{time:1200,icon:5});

                    }

                }) 

            layer.close(index);

            });

	});



	//查看详情

    $('.details-btn').on('click', function(){

        let id = $(this).data('id');console.log(id);

        let url = "{:cmf_plugin_url('Store://admin_index/storeinfo')}?noNav=1&store_id="+id;

        layer.open({

        type: 2

        ,title: '查看'

        ,shadeClose: true

        ,shade: 0.8

        ,area: ['800px', '800px']

        ,btn:['关闭']

        ,fixed:false

        ,content: url //iframe的url

        ,btn2:function(index, layero){}

        });

    });







	//审核日志

	$('.log-btn').on('click',function(){

        let id = $(this).data('id');

		let url = "{:cmf_plugin_url('Store://audit_store/logPage')}?id="+id;

		layer.open({

			type: 2//基本层类型  0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）

			,title: '日志'//层的标题

			,shadeClose: true//是否点击遮罩关闭

			,shade: 0.8//遮罩

			,area: ['800px', '700px']//宽高

			,btn:['关闭']//弹框按钮

			,fixed:false//固定

			,content: url //iframe的url

			,btn2:function(index, layero){

			}

		});

	});



    </script>

</body>

</html>